// 自定义滚动条
import PerfectScrollbar from 'perfect-scrollbar';
// 对应的css
import 'perfect-scrollbar/css/perfect-scrollbar.css';
const directive = {
  bind(el, binding, vnode) {
    // const initHeight = binding.value;
    // const elInput = el.querySelector('.el-input');
    // const elInputInner = elInput.querySelector('.el-input__inner');
    // elInput.style.height = initHeight + 'px';
    // setTimeout(() => {
    //   elInputInner.style.height = `${initHeight}px !important;`;
    //   console.log(elInputInner);
    // }, 1000);
  },
  inserted(el, binding) {
    const isOpenScroll = binding.value === undefined ? true : binding.value;
    if (el && isOpenScroll) {
      let scrollContainer = el.querySelector('.el-cascader__tags');
      if (!scrollContainer) {
        scrollContainer = el.querySelector('.el-select__tags');
      } else {
        const search = scrollContainer.querySelector('.el-cascader__search-input');
        if (search) search.style.height = '22px';
      }
      el.className += ' multiply-select-scroll';
      if (scrollContainer) {
        el.ps = new PerfectScrollbar(scrollContainer, {
          suppressScrollX: true
        });
      }
    }
  },
  update(el) {
    if (el.ps) {
      el.ps.update();
    }
  }
};

export default {}.install = (Vue, options = {}) => {
  Vue.directive('selectScroll', directive);
};
